<template>
  <div id="titleDetail">
    <navbar>
      <template v-slot:left>
        <div class="imgLeft" @click="backLast">
          <img src="~assets/img/common/back.svg" alt="" />
        </div>
      </template>
      <template v-slot:center>
        <div class="title">
          <p
            v-for="(item, index) in title"
            :key="index"
            class="titleItem"
            :class="{ active: index === currentIndex }"
            @click="titleClick(index)"
          >
            {{ item }}
          </p>
        </div>
      </template>
    </navbar>
  </div>
</template>

<script>
import Navbar from "components/common/navbar/Navbar";

export default {
  name: "titleDetail",
  components: {
    Navbar,
  },
  data() {
    return {
      title: ["商品", "参数", "评论", "推荐"],
      currentIndex: 0,
    };
  },
  methods: {
    titleClick(e) {
      this.currentIndex = e;
      this.$emit("clickTheme", e);
    },
    backLast() {
      this.$router.go(-1);
    },
  },
};
</script>

<style scoped>
.title {
  display: flex;
  font-size: 14px;
}
.titleItem {
  flex: 1;
}
.active {
  color: var(--color-high-text);
}
.imgLeft img {
  margin-top: 17%;
}
</style>